package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appmarket.service.store.awk.bean.SafeAppCardBean;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.LinkedHashMap;
import java.util.Locale;
import o.djr.e;
import o.ewm.n;

public class dkh {
    protected static void ॱ(final DownloadButton downloadButton, BaseDistCardBean baseDistCardBean) {
        if (downloadButton.getContext().getPackageName().equals(baseDistCardBean.ॱـ())) {
            evk.ˋ(downloadButton.getContext(), downloadButton.getContext().getString(n.ˑʼ), 0).ˋ();
        } else if (((cdg) cdb.ॱ(cdg.class)).ʽ(baseDistCardBean.ॱـ())) {
            evk.ˋ(downloadButton.getContext(), downloadButton.getContext().getString(n.ʻॱ), 0).ˋ();
        } else if (baseDistCardBean.ˈ()) {
            ˊ(downloadButton.getContext(), baseDistCardBean.ʼ());
        } else if (baseDistCardBean.ᐝॱ() && !ebz.ॱ().ˎ(baseDistCardBean.ॱـ())) {
            downloadButton.setEventProcessing(true);
            downloadButton.setEnabled(false);
            new eci(baseDistCardBean, downloadButton.getContext(), new e() {
                public void ॱ(Context context, BaseDistCardBean baseDistCardBean) {
                    if (Logger.ˎ()) {
                        Logger.ˏ("OpenAppUtil", "in case OpenApp PayAuthenticate process successed.");
                    }
                    downloadButton.setEventProcessing(false);
                    downloadButton.setEnabled(true);
                    dvq.ˊ(ContentManager.getInstant().getContext(), null, 0);
                }

                public void ˋ() {
                    Logger.ˏ("OpenAppUtil", "in case OpenApp PayAuthenticate process failed.");
                    downloadButton.setEventProcessing(false);
                    downloadButton.setEnabled(true);
                }
            }).ˋ();
        } else if (dof.ॱ(baseDistCardBean.ˊʼ())) {
            if (baseDistCardBean instanceof SafeAppCardBean) {
                SafeAppCardBean safeAppCardBean = (SafeAppCardBean) baseDistCardBean;
                String ॱꞌ = safeAppCardBean.ॱꞌ();
                if (!dof.ॱ(ॱꞌ)) {
                    ˊ(downloadButton.getContext(), safeAppCardBean, ॱꞌ, "");
                    return;
                }
            }
            boolean ˎ = ced.ˎ(downloadButton.getContext(), baseDistCardBean.ॱـ(), baseDistCardBean.v_());
            if (Logger.ˎ()) {
                Logger.ˏ("OpenAppUtil", "launchStatus=" + ˎ);
            }
            if (ˎ) {
                djx.ˏ(baseDistCardBean, downloadButton.getContext());
            }
        } else {
            ˋ(downloadButton.getContext(), baseDistCardBean);
        }
    }

    private static void ˋ(Context context, BaseDistCardBean baseDistCardBean) {
        int i;
        String ॱॱ = baseDistCardBean.ॱॱ();
        String ˊʼ = baseDistCardBean.ˊʼ();
        String ॱـ = baseDistCardBean.ॱـ();
        int ˎ = dgm.ˎ((Activity) context);
        try {
            Intent intent = new Intent();
            intent.setAction(ACTION.HWID_SCHEME_URL);
            intent.setData(Uri.parse(ˊʼ));
            intent.setFlags(268435456);
            intent.setPackage(ॱـ);
            context.startActivity(intent);
            i = 0;
            cgo.ˋ(HwAccountConstants.TYPE_SECURITY_PHONE, ॱॱ, ˎ);
        } catch (Exception e) {
            Logger.ˏ("OpenAppUtil", e.toString());
            i = -1;
            if (ced.ˎ(context, ॱـ, baseDistCardBean.v_())) {
                djx.ˏ(baseDistCardBean, context);
            }
        }
        dgh.ˋ("340301", evg.ॱ(ˊʼ, ॱॱ, ॱـ, ˎ, i));
    }

    public static void ˊ(Context context, BaseDistCardBean baseDistCardBean, String str, String str2) {
        int i;
        String ॱॱ = baseDistCardBean.ॱॱ();
        String ॱـ = baseDistCardBean.ॱـ();
        int ˎ = dgm.ˎ((Activity) context);
        try {
            Intent intent = new Intent();
            intent.setAction(ACTION.HWID_SCHEME_URL);
            intent.setData(Uri.parse(str));
            if (!str.toLowerCase(Locale.ENGLISH).startsWith("http")) {
                intent.setFlags(268435456);
                intent.setPackage(ॱـ);
            }
            context.startActivity(intent);
            i = 0;
            cgo.ˋ(HwAccountConstants.TYPE_SECURITY_PHONE, ॱॱ, ˎ);
        } catch (Exception e) {
            Logger.ˏ("OpenAppUtil", e.toString());
            i = -1;
            if (ced.ˎ(context, ॱـ, baseDistCardBean.v_())) {
                djx.ˏ(baseDistCardBean, context);
            }
        }
        LinkedHashMap ॱ = evg.ॱ(str, ॱॱ, ॱـ, ˎ, i);
        if (!dof.ॱ(str2)) {
            ॱ.put("anchor", str2);
        }
        dgh.ˋ("340301", ॱ);
    }

    private static void ˊ(Context context, String str) {
        if (context != null && !TextUtils.isEmpty(str)) {
            try {
                Intent intent = new Intent(ACTION.HWID_SCHEME_URL, Uri.parse(str));
                intent.setFlags(268435456);
                context.startActivity(intent);
            } catch (Exception e) {
                Logger.ˋ("OpenAppUtil", "open no-gms url error.: " + e.getMessage());
            }
        }
    }
}
